package io;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class Demo02 {
    public static void main(String[] args) {
        //1.创建流
        String data = "java so easy";
        //2.创建流流
        try {
            //append参数：如果 append参数为true写入字符追加在字符末尾，append参数默认为false
            FileOutputStream fos = new FileOutputStream("E:\\a.txt",true);
//      3.输出流
            //字符串装换为字符数组  getBytes()
            //write()方法如果文件不存在，则创建文件
            fos.write(data.getBytes());
//       4.关闭流
            fos.close();
        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }

    }
}
